<template>
  <div>
    <van-row class="van-2">
      <van-col span="8"><van-icon name="arrow-left" @click="$router.go(-1)" /></van-col>
      <van-col span="8">客户列表信息</van-col>
      <van-col
        span="8"
        class="van-1"
        @click="$router.push(`/visitnew`)"
        >新增</van-col
      >
    </van-row>
    <form action="/">
      <van-search
        v-model="value"
        show-action
        placeholder="请输入搜索关键词"
        @search="onSearch"
        @cancel="onCancel"
        action-text="搜索"
      />
    </form>
    <van-row class="box"  v-for="(item,index) in records" :key="index" @click="addresc(item.custName,item.id)">
      <van-col span="4"
        ><img src="../assets/客户关怀/头像.png" alt=""
      /></van-col>
      <van-col span="16">{{item.custName}}</van-col>
      <van-col span="4"><van-icon name="arrow" /></van-col>
    </van-row>
  </div>
</template>

<script>
import {CustuserData} from '../request/api'
export default {
  data() {
    return {
      value: "",
      searc: "",
    records:[],
    custNameid:'',
   
    };
  },
  methods: {
    onSearch(val) {
      this.searc = val;
      console.log(this.searc, 123);
    },
    onCancel() {},
    addresc(val,index){
      console.log(val,index);
      this.custNameid=val
      
      this.$router.push(`visitnew?id=${this.custNameid}&getid=${index}`)
    }
  },
  created(){
    CustuserData({
      keyword:this.value,
      current:'1',
      size:'100'
    }).then(res=>{
      console.log(res.data.records);
      this.records=res.data.records
    })
  }
  
};
</script>
 
<style lang = "less" scoped>
.van-2 {
  padding: 15px 10px;
  background-color: blue;
}
.van-1 {
  text-align: right;
}
.box{
    background-color: #efefef;
    line-height: 40px;
    padding: 15px;
    border-bottom: 1px solid #ccc;
    img{
        width: 40px;
        height: 40px;
    }
}
</style>